// 商品信息
module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;

  const CommoditySchema = new Schema({
    name: { type: String },
    /**
     * 这里改动为数组
     * 存入多个图片的objectId
     */
    picture: [String],
    price: { type: Number },
    vipPrice: { type: Number },
    // 折扣
    discount: { type: Number },
    // 用来排序
    sort: { type: Number },
    menuId: { type: Schema.Types.ObjectId, ref: "Banner" },
    createAt: {
      type: Date,
      default: Date.now
    },
    updateAt: {
      type: Date,
      default: Date.now
    }
  });
  return mongoose.model("Commodity", CommoditySchema);
};
